<include file="../Public/header" />
<!--添加样式-->
<style type="text/css">
    .m-i-body .m-i-b-p{margin-left: 1em;margin-right: 1em}
    .microblog-item{margin-bottom: 0.75em;}
    .m-i-footer{padding:0.25em 0.75em;margin:0;}
    .c_comments{margin:0 0.75em;}
    #ts-list .m-i-b-p-100{margin:0 1em 0.75em 1em;}
    .m-i-b-p-repost,#ts-list .m-i-b-p-repost .m-i-b-p-100{margin:0;display: block;}

</style>
<div id="content" class="content">
    <div id="detail" data-title="分享正文" class="panel" data-selected="true"  data-menu="msgmenu">
        <header>
            <div id="header-buttons">
                <div id="back" class="header-menu-link">
                </div>
                <div id="messageLink" class="header-menu-link"><a href="{:U('w3g/Index/msgbox')}"><i class="num"></i></a></div>
        <div id="menuLink" class="header-menu-link"></div>
            </div>
            <h1 class="hasback">
                分享正文
            </h1>
        </header>
    <!-- 下载手机客户端 -->
    <div id="app-down-box" class="app-down-box">
        <div class="app-down">
            <a class="ico-close2 ts-listen" data-listen="weibo-remove-click" data-for="app-down-box" href="javascript:;"></a>
            下载客户端，发现更多精彩
        </div>
    </div>
        <div id="ts-list">
            <div class="microblog-item">
                <!-- header -->
                <div class="media m-i-header">
                    <div class="pull-left m-i-h-avatar ts-listen" data-listen="weibo-userpage-{$feed['uid']}">
                        <img class="media-object m-i-h-a-img" src="{$feed['avatar_small']}"><php>if($feed['user_gicon']):</php><a href="javascript:;" title="{$feed['user_gicon']['user_group_name']}" class="group_icon_only"><img alt="{$feed['user_gicon']['user_group_name']}" src="{$feed['user_gicon']['user_group_icon_url']}" ></a><php>endif;</php>
                    </div>
                    <div class="media-body m-i-h-info ts-listen" data-listen="weibo-userpage-{$feed.uid}">
                        <div class="m-i-h-i-l-name">{$feed['uname']}</div>
                        <div class="m-i-h-i-l-description">{$feed.publish_time|friendlyDate}&nbsp;&nbsp;{$feed.from}</div>
                    </div>
                    <div class="m-i-h-right">
                    </div>
                </div>
                <!-- body -->
                <div class="m-i-body">
                    <p class="m-i-b-p" id="m-i-b-p-{$feed.feed_id}">
                        {$feed['content']}
                    </p>
                    <php>
                        switch($feed['type']){
                        case 'postimage':
                        switch(count($feed['attach'])){
                        case 1:
                        $img_class='m-i-b-p-100';
                        break;
                        case 2:
                        $img_class='m-i-b-p-50';
                        break;
                        default:
                        $img_class='m-i-b-p';
                        break;
                        }
                        echo '<div class="m-i-b-p-100">';
                        foreach($feed['attach'] as $k => $v){
                        //dump($v);
                        
                        echo '<img src="'.$v['attach_middle'].'" alt="" class="ts-listen" data-listen="weibo-pic-view" data-src="'.$v['attach_url'].'" data-index="'.$k.'"/>';
                        
                        }
                        echo '</div>';
                        break;
                        case 'repost':
                        echo '<div id="repost-'.$feed[feed_id].'" class="m-i-b-p m-i-b-p-repost"><span class="ts-listen" data-listen="weibo-userpage-'.$feed['transpond_data']['uid'].'">'.$feed['transpond_data']['uname'].'</span>: '.$feed['transpond_data']['content'].'</div>';
                        break;
                        case 'repost-postimage':
                        echo '<div id="repost-'.$feed[feed_id].'" class="m-i-b-p m-i-b-p-repost"><span class="ts-listen" data-listen="weibo-userpage-'.$feed['transpond_data']['uid'].'">'.$feed['transpond_data']['uname'].'</span>: '.$feed['transpond_data']['content'];
                        switch(count($feed['transpond_data']['attach'])){
                            case 1:
                            $img_class='m-i-b-p-100';
                            break;
                            case 2:
                            $img_class='m-i-b-p-50';
                            break;
                            default:
                            $img_class='m-i-b-p';
                            break;
                        }
                        echo '<div class="m-i-b-p-100" style="margin-top:0.75em">';
                            foreach($feed['transpond_data']['attach'] as $k => $v){
                            
                            echo '<img src="'.$v['attach_middle'].'" alt="" class="ts-listen" data-listen="weibo-pic-view" data-src="'.$v['attach_url'].'" data-index="'.$k.'"/>';
                            
                            }
                            echo '</div></div>';
                        break;
                        case 'repost-removed':
                        echo '<div id="repost-'.$feed[feed_id].'" class="m-i-b-p  m-i-b-p-repost"><span class="ts-listen" data-listen="weibo-userpage-'.$feed['transpond_data']['uid'].'">'.$feed['transpond_data']['uname'].'</span>: 这条分享不幸被删除了...</div>';
                        break;
                        case 'weiba_repost':
                                    echo '<p id="repost-'.$feed[feed_id].'" class="m-i-b-p  m-i-b-p-repost">转载自<span class="ts-listen" data-listen="weibo-weibapage-'.$feed['api_source']['feed_id'].'">'.$feed['api_source']['weiba_name'].'</span><font class="ts-listen" data-listen="weibo-weibadetail-'.$feed['api_source']['source_id'].'">'.$feed['api_source']['title'].'</font><p>';
                                        break;
                                    case 'weiba_repost-removed':
                                        echo '<p id="repost-'.$feed[feed_id].'" class="m-i-b-p  m-i-b-p-repost">原帖子已删除<p>';
                                        break;
                        case 'postfile':
                        echo '<div style="padding:0 0.75em;">';
                        for($i=0;$i<count($feed['attach']);$i++){
                            //dump($feed['attach'][$i]);
                            </php>
                            <a href="{:U('widget/Upload/down', array('attach_id'=>$feed['attach'][$i]['attach_id']))}" target="_blank" class="downloadbox">
                                <div class="pure-g">
                                    <div class="d-name pure-u-3-4">
                                        {$feed['attach'][$i]['attach_name']}
                                        <span>{$feed['attach'][$i]['size']}</span>
                                    </div>
                                    <div class="pure-u-1-4">
                                        <span class="fa fa-download"></span>
                                    </div>
                                </div>
                            </a>
                            <php>

                        }
                        echo '</div>';
                        break;
                    case 'repost-postfile':
                        echo '<div style="padding:0 0.75em">';
                        for($i=0;$i<count($feed['api_source']['attach']);$i++){
                        </php>
                        <a href="{:U('widget/Upload/down', array('attach_id'=>$feed['api_source']['attach'][$i]['attach_id']))}" target="_blank" class="downloadbox">
                            <div class="pure-g">
                                <div class="d-name pure-u-3-4">
                                   {$feed['transpond_data']['attach'][$i]['attach_name']}
                                    <span>{$feed['transpond_data']['attach'][$i]['size']}</span>
                                </div>
                                <div class="pure-u-1-4">
                                    <span class="fa fa-download"></span>
                                </div>
                            </div>
                        </a>
                        <php>
                            //var_dump($feed['api_source']['attach'][$i]);
                        }
                        echo '</div>';
                        break;
                        case 'postvideo':
                        if(preg_match("/(thinksns\.com)/i", $feed['flashvar'])){
                        echo '<div class="m-i-b-p-video-box ts-listen" data-video="'.$feed['flashvar'].'" data-listen="weibo-video-view">';
                        echo '<div class="playico fa fa-play"></div>';
                        echo '<img src="'.$feed['flashimg'].'" alt="video" class="m-i-b-p-video-img"/>';
                        echo '</div>';
                        }
                        break;
                        case 'repost-postvideo':
                        echo '<div id="repost-'.$feed[feed_id].'" class="m-i-b-p m-i-b-p-repost"><span>'.$feed['transpond_data']['uname'].'</span>: '.$feed['transpond_data']['content'];
                            if(preg_match("/(thinksns\.com)/i", $feed['transpond_data']['flashvar'])){
                            echo '<div class="m-i-b-p-video-box ts-listen" data-video="'.$feed['transpond_data']['flashvar'].'" data-listen="weibo-video-view">';
                            echo '<div class="playico fa fa-play"></div>';
                            echo '<img src="'.$feed['transpond_data']['flashimg'].'" alt="video" class="m-i-b-p-video-img"/>';
                            echo '</div>';
                            }
                        echo '</div>';
                        break;
                        default:
                        break;
                        }
                    </php>
                </div>
            </div>
            <div id="m-i-footer-{$feed.feed_id}" class="m-i-footer">
                <div class="pure-g" data-uname="{$feed.uname}" data-uid="{$feed.uid}">
                    <div class="pure-u-1-4 ts-textcenter ts-listen" data-listen="weibo-list2retweet-{$feed.feed_id}" data-share="1" data-origin="{$feed.cancomment}" data-repost="{$feed['repost']}">
                        <div class="weibo-item-btn weibo-item-btn-retweet"></div>
                        <span class="ts-number">{$feed['repost_count']}</span>
                    </div>
                    <div class="pure-u-1-4 ts-textcenter ts-listen" data-listen="weibo-list2reply-{$feed.feed_id}" data-share="1" data-origin="{$feed.cancomment}" data-curorigin="{$feed.cancomment_current}" data-repost="{$feed['repost']}">
                        <div class="weibo-item-btn weibo-item-btn-reply"></div>
                        <span class="ts-number">{$feed['comment_count']}</span>
                    </div>
                    <php>
                        if($feed['is_digg']==1){
                        $purelight='pure-light';
                        }else{
                        $purelight='';
                        }
                    </php>
                    <div class="pure-u-1-4 ts-textcenter ts-listen {$purelight}" data-listen="weibo-list2digg-{$feed.feed_id}" data-isdig="{$feed['is_digg']}">
                        <div class="weibo-item-btn weibo-item-btn-like"></div>
                        <span class="ts-number">{$feed['digg_count']}</span>
                    </div>
                    <php>
                        if($feed['favorited']==1){
                        $fa_star='fa-star';
                        $purelight='pure-light';
                        }else{
                        $fa_star='fa-star-o';
                        $purelight='';
                        }
                    </php>
                    <div class="pure-u-1-4 ts-textcenter ts-listen {$purelight}" data-listen="weibo-list2favorite-{$feed.feed_id}" data-isstar="{$feed['favorited']}" data-type="{$feed.app_row_table}">
                        <div class="weibo-item-btn weibo-item-btn-star"></div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 评论回复框 -->
        <div class="pure-form" id="weibo-detail-toreplybox">
            <div class="pure-div pure-input-1 ts-listen" data-listen="weibo-list2reply-{$feed.feed_id}" data-share="1" data-origin="{$feed.cancomment}" data-curorigin="{$feed.cancomment_current}" data-repost="{$feed['repost']}">
                回复
            </div>
        </div>
        <!-- 评论列表 -->
        <div id="c_comment_box" class="ts-clearboth">
            <!-- 循环开始 -->
            <volist name="comment" id="vo">
                <div class="c_comments ts-clearboth ts-padding10 ts-borderbottom" touid="{$vo['user_info']['uid']}" rowid="{$vo.row_id}" appuid="{$vo.app_uid}" ccid="{$vo.comment_id}">
                    <!--这里的ccid为评论id  appuid为分享详情页原分享作者的ID rowid为原分享ID touid为原评论者的ID  -->
                    <div class="c_comments_ava ts-floatleft">
                        <a href="javascript:;" class="ts-listen" data-listen="weibo-userpage-{$vo['user_info']['uid']}">
                            <img src="{$vo['user_info']['avatar_small']}" width=40 height=40>
                        </a>
                    </div>
                    <div class="c_comments_content">
                        <div class="c_comments_content_info">
                            <div class="c_comments_content_info_name" id="cc_name_{$vo.comment_id}">{$vo['user_info']['uname']}</div>
                            <div class="c_comments_content_info_time">
                                <php>$ctime=strtotime($vo[ctime])</php>{$ctime|friendlyDate}
                            </div>
                        </div>
                        <p class="c_comments_content_p">
                            <php>
                                $content = wapFormatContent($vo['content']);
                                $content = preg_replace('/^回复\<a/i','<a data-ignore="true" ',$content);
                                echo $content;
                            </php>
                        </p>
                        <div class="c_comments_reply ts-font fa-reply ts-listen" data-listen="weibo-list2reply-{$feed.feed_id}" data-query="&to_uid={$vo['user_info']['uid']}&to_uname={$vo['user_info']['uname']}&to_comment_id={$vo.comment_id}" data-share="1" data-origin="{$feed.cancomment}" data-curorigin="{$feed.cancomment_current}" data-repost="{$feed['repost']}" data-ccid="{$vo.comment_id}"></div>
                    </div>
                </div>
            </volist>
            <!-- 循环结束 -->
            <!-- 分页 -->
            <php>if($count>20){</php>
            <div id="pager_box">
                <php>if(empty($_GET['page']) || $_GET['page']==1){</php>
                    <a href="javascript:;" link="" id="prev" class="pure-button pager_child pager_p_n_none pure-button-disabled">上一页</a>
                <php>}else{</php>
                    <a href="{:U('w3g/Index/detail', array('weibo_id'=>$_GET['weibo_id'], 'page'=>$page-1))}" id="prev" class="pure-button pager_child pager_p_n pure-button-primary">上一页</a>
                <php>}</php>
                <select id="page_sel" class="pure-button pager_child ts-listen"  data-listen="weibo-pagerSelect-change">
                    <php>
                        $_GET['page']!=0?$get=$_GET['page']:$get=1;
                        $_count = ceil($count/20);
                        if($get<6){
                        for($i=0;$i<($_count);$i++){
                        $get==$i+1?$selected='selected="selected"':$selected='';
                        if($i>9){
                        break;
                        }
                    </php>
                    <option data-index="{$i}" value="{:U('w3g/Index/detail', array('weibo_id'=>$_GET['weibo_id'], 'page'=>$i+1))}" <php>echo $selected;</php>>第{$i+1}页</option>
                    <php>	}
                        }elseif($get>=6){
                        for($i=($get-5);$i<$get;$i++){
                        $get==$i+1?$selected='selected="selected"':$selected='';
                    </php>
                    <option data-index="{$i}" value="{:U('w3g/Index/detail', array('weibo_id'=>$_GET['weibo_id'], 'page'=>$i+1))}" <php>echo $selected;</php>>第{$i+1}页</option>
                    <php>	}</php>
                    <php>	for($i=$get;$i<($get+5);$i++){
                        $get==$i+1?$selected='selected="selected"':$selected='';
                        if($i>$_count-1){
                        break;
                        }
                    </php>
                    <option data-index="{$i}" value="{:U('w3g/Index/detail', array('weibo_id'=>$_GET['weibo_id'], 'page'=>$i+1))}" <php>echo $selected;</php>>第{$i+1}页</option>
                    <php>	}</php>
                    <php>}</php>

                </select>
                <php>if($get == $_count) {</php>
                <a href="javascript:;" link="" id="next" class="pure-button pager_child pager_p_n_none pure-button-disabled">下一页</a>
                <php>}else{</php>
                <a href="{:U('w3g/Index/detail', array('weibo_id'=>$_GET['weibo_id'], 'page'=>$page+1))}" id="next" class="pure-button pager_child pager_p_n pure-button-primary">下一页</a>
                <php>}</php>
            </div>
            <php>}</php>
        </div>
    </div>
    <script>
        $(document).ready(function(){
            var mid = "{$uid}";
            if(!~~mid){
                $('#content .ts-listen').addClass('ts-login').removeClass('ts-listen');
                 $('#content .ts-login').bind('click',function(){
                    window.location.href = U('w3g/Index/index');
                });
           }
            TS.cache.detailId='{$feed['feed_id']}';
            TS.cache.app_uid='{$feed['uid']}';
            TS.cache.at='{$feed['uname']}';
            TS.cache.pageType='detail';
        });
        var detailLoad = function(el){
            window.setTimeout(function(){
                $("#header #menubadge").css("float","right");
            },200);
        };
        <php>if($_GET['type'] == 'c_comment_box'){</php>
            var comment_list_box = document.getElementById("c_comment_box");
            (comment_list_box.offsetTop+'px');
        <php>}</php>
    </script>
<include file="../Public/footer" />